package org.vectrics.skill.struts;

import java.util.List;

import org.apache.ecs.html.Form;
import org.vectrics.common.html.Combo;
import org.vectrics.common.view.HtmlForm;
import org.vectrics.common.view.HtmlFormEditRow;
import org.vectrics.evaluation.EvaluationType;
import org.vectrics.recruiter.RecruitServiceLocator;
import org.vectrics.recruiter.struts.admin.job.JobEditFormTag;
import org.vectrics.struts.VectricsTagSupport;

public class UserEvaluationEditTag extends VectricsTagSupport {

	private static final long serialVersionUID = 5753340420714663213L;

	@Override
	protected String makeStartTag() {
		HtmlForm form = new HtmlForm(this.getRequest(), "evaluationForm", this.getPhrase("phrase.evaluation.information"));
		form.setWidth(580);
		form.setMethod(Form.POST);
		form.addHidden("evaluationId", this.getRequest().getParameter("evaluationId"));
		form.setId(JobEditFormTag.FORM_ID);
		form.setAction(this.getContextPath() + "/admin/user/eval/save.do");
		form.addPersonPicker(this.getPhrase("prompt.person"), "userId", this.getContextPath(), true);
		form.addPersonPicker(this.getPhrase("prompt.evaluator"), "evaluatorId", this.getContextPath(), true);
		
		HtmlFormEditRow descriptionRow = (HtmlFormEditRow) form.addEditForParam
			(this.getPhrase("prompt.evaluation.description") + " *", "description", true);
		descriptionRow.getEditBox().setMaxlength(100);
		
		HtmlFormEditRow score = (HtmlFormEditRow) form.addEditForParam(this.getPhrase("prompt.evaluation.score") + " *", "score", true);
		score.getEditBox().setMaxlength(3);
        score.getEditBox().setOnKeyPress(" return soloNumerosEnteros(event, this);");
		
		Combo typeCombo = new Combo();
		List<EvaluationType> evaluationTypes = RecruitServiceLocator.getSkillProvider().getTypeEvaluation();
		for (EvaluationType evaluationType : evaluationTypes) {
			typeCombo.addOption(evaluationType.getDescription(),evaluationType.getId().toString());
		}
		form.addComboRowForParam(this.getPhrase("prompt.evaluation.type"), "type" , typeCombo, true);
		int noteTextRows = 15;
		int noteTextCols = 70;
		form.addTextAreaRowForParam(this.getPhrase("prompt.notes"), "notes", noteTextRows, noteTextCols, false);
		form.addSubmitAndCancelButton();
		
		return(form.toString());
	}

}
